package com.zqq.baselibrary.http.rx

import com.zqq.baselibrary.presenter.view.BaseView
import rx.Subscriber

/**
 * Rx订阅者默认实现
 *      因为需要进行关闭loading，所以把view通过构造方法传进来
 * wc
 * @author zqq on 2018/7/26
 */
open class BaseSubscriber<T>(val baseView: BaseView) : Subscriber<T>() {

    override fun onNext(t: T) {
    }

    override fun onCompleted() {
        baseView.hideLoading()
    }

    override fun onError(e: Throwable) {
        baseView.hideLoading()
        if (e is BaseException) {
            baseView.onError(e.msg)
        }
        baseView.onError(e.message!!)
    }

}